@extends('admin.app')

@section('breadcrumb')
    <div class="bg-light lter b-b wrapper-md">
        <ol class="breadcrumb bg-light lter m-n no-padder">
            <li><a href="{{ admin_action('HomeController@index') }}">主页</a></li>
            <li>网站管理</li>
            <li class="active">友情链接管理</li>
        </ol>
    </div>
@endsection

@section('content')
    <div class="panel panel-default">
        <div class="panel-heading font-bold">
            友情链接列表
        </div>
        <div class="row wrapper">
            <div class="col-sm-8">
                <form class="form-horizontal" method="get"
                      action="{{ admin_action('Web\FriendlyLinksController@index') }}">
                    <div class="row">
                        <div class="col-sm-5">
                            <div class="form-group">
                                <label class="control-label col-sm-4">链接名称:</label>
                                <div class="col-sm-8">
                                    <input class="form-control" type="text" placeholder="请输入链接名称" name="name"
                                           value="{{ $query['name'] }}"/>
                                </div>
                            </div>
                        </div>

                        <div class="col-sm-5">
                            <div class="form-group">
                                <label class="control-label col-sm-4">友情链接类型:</label>
                                <div class="col-sm-8">
                                    <select name="link_type" class="form-control select2">
                                        <option value="">----请选择链接类型----</option>
                                        @foreach( $link_types as $link_type)
                                            @if($link_type->code == $query['link_type'])
                                                <option value="{{ $link_type->code }}"
                                                        selected="selected">{{ $link_type->name }}</option>
                                            @else
                                                <option value="{{ $link_type->code }}">{{ $link_type->name }}</option>
                                            @endif
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-1 text-left">
            <span class="input-group-btn">
              <button class="btn btn-sm btn-default" type="submit">查询</button>
            </span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="col-sm-4 text-right text-center-xs">
                @accredit('web.navigations.create')
                <a class="btn m-b-xs btn-sm btn-default btn-addon"
                   href="{{ admin_action('Web\FriendlyLinksController@create') }}">
                    <i class="fa fa-plus"></i>新增友情链接记录
                </a>
                @endaccredit
            </div>
        </div>
        <div class="table-responsive">
            <table class="table table-striped b-t b-light">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>名称</th>
                    <th>链接类型</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @forelse ($friendly_links as $friendly_link)
                    <tr>
                        <td>{{ $friendly_link->id }}</td>
                        <td>{{ $friendly_link->name }}</td>
                        <td>{{ $friendly_link->code()->name }}</td>
                        <td>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Web\FriendlyLinksController@show', [$friendly_link]) }}"
                               data-toggle="tooltip" title="查看该友情链接详情">
                                <i class="fa fa-info"></i>
                            </a>
                            <a class="btn btn-xs btn-primary"
                               href="{{ admin_action('Web\FriendlyLinksController@edit', [$friendly_link]) }}"
                               data-toggle="tooltip" title="编辑该友情链接">
                                <i class="fa fa-pencil"></i>
                            </a>
                            <form class="inline"
                                  action="{{ admin_action('Web\FriendlyLinksController@destroy', [$friendly_link]) }}"
                                  method="post">
                                {{ csrf_field() }}
                                {{ method_field('DELETE') }}
                                <button type="button" data-swal-role="delete-confirm" data-swal-title="温馨提示"
                                        data-swal-text="您将删除友情链接 <{{ $friendly_link->name }}>   "
                                        class="btn btn-xs btn-danger" data-toggle="tooltip" title="删除导航信息">
                                    <i class="fa fa-trash-o"></i>
                                </button>
                            </form>
                        </td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="3" class="text-center">没有找到友情链接记录</td>
                    </tr>
                @endforelse
                </tbody>
            </table>
        </div>
        <div class="panel-footer">
            <div class="row">
                <div class="col-sm-12 text-right text-center-xs">
                    {!! $links !!}
                </div>
            </div>
        </div>
    </div>
@endsection